home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / cenviw1.zip / MSGBOX.LIB < prev    next >
Text File  |  1993-06-25  |  4KB  |  61 lines

  1. // MsgBox.lib - Cmm code wrapper for the MessageBox function.  This library
  2. //              can be included in your source file to provide access to
  3. //              to Windows' MessageBox() function.  The Windows MessageBox()
  4. //              function takes a parent window handle as the first paramter,
  5. //              but this wrapper simplifies it by automatically selecting
  6. //              NULL as the parent window, which is OK for a modal function.
  7. //
  8. // FUNCTION: MessageBox()
  9. // SYNTAX: MessageBox(MessageText[,BoxTitle[,TypeFlags]])
  10. //   MessageText: Text string to display in the message box.
  11. //   BoxTitle: Title to display on the box.  If NULL or this parameter is
  12. //             not supplied then Windows defaults to the string "Error"
  13. //   TypeFlags: a number of flags, or'ed together to specify the behavior
  14. //              of the message box.  If this parameter is not supplied then
  15. //              it defaults to MB_OK | MB_TASKMODAL.  Possible flags are:
  16.       #define MB_OK               0x0000  // Message box contains one push button: OK.
  17.       #define MB_OKCANCEL         0x0001  // Message box contains two push buttons: OK and Cancel.
  18.       #define MB_ABORTRETRYIGNORE 0x0002  // Message box contains three push buttons: Abort, Retry, and Ignore.
  19.       #define MB_YESNOCANCEL      0x0003  // Message box contains three push buttons: Yes, No, and Cancel.
  20.       #define MB_YESNO            0x0004  // Message box contains two push buttons: Yes and No.
  21.       #define MB_RETRYCANCEL      0x0005  // Message box contains two push buttons: Retry and Cancel.
  22.       #define MB_ICONSTOP         0x0010  // A stop sign icon appears in the message box.
  23.       #define MB_ICONHAND         0x0010  // Same as MB_ICONSTOP.
  24.       #define MB_ICONQUESTION     0x0020  // A question-mark icon appears in the message box.
  25.       #define MB_ICONEXCLAMATION  0x0030  // An exclamation-point icon appears in the message box.
  26.       #define MB_ICONINFORMATION  0x0040  // An icon consisting of a lowercase i in a circle
  27.                                           // appears in the message box.
  28.       #define MB_DEFBUTTON1       0x0000  // First button is the default. This is the default.
  29.       #define MB_DEFBUTTON2       0x0100  // Second button is the default.
  30.       #define MB_DEFBUTTON3       0x0200  // Third button is the default.
  31.       #define MB_APPLMODAL        0x0000  // Must respond to this message box before continuing in this application.
  32.       #define MB_SYSTEMMODAL      0x1000  // Must respond to this message box before any application may resume.
  33.       #define MB_TASKMODAL        0x2000  // Must respond to this message box before continuing in this application.
  34. // RETURN:   Returns zero if there is insufficient memory to create the box;
  35. //           otherwise returns one of these values:
  36.       #define IDOK                1       // OK button pressed
  37.       #define IDCANCEL            2       // Cancel button pressed
  38.       #define IDABORT             3       // Abort button pressed
  39.       #define IDRETRY             4       // Retry button pressed
  40.       #define IDIGNORE            5       // Ignore button pressed
  41.       #define IDYES               6       // Yes button pressed
  42.       #define IDNO                7       // "No" button pressed
  43.  
  44.  
  45. MessageBox(MessageText,BoxTitle,TypeFlags)
  46. {
  47.    // BoxTitle and TypeFlags are optional, and so check for their existence
  48.    // or else take defaults
  49.    ParameterCount = va_arg();
  50.    mbTitle = ( ParameterCount < 2 ) ? NULL : BoxTitle ;
  51.    mbFlags = ( ParameterCount < 3 ) ? (MB_OK | MB_TASKMODAL) : TypeFlags ;
  52.    // use DynamicLink to call the MessageBox() routine.
  53.    mbResult = ( mbTitle == NULL )
  54.             ? DynamicLink("USER","MESSAGEBOX",SWORD16,PASCAL,
  55.                           NULL,MessageText,0,0,mbFlags)
  56.             : DynamicLink("USER","MESSAGEBOX",SWORD16,PASCAL,
  57.                           NULL,MessageText,mbTitle,mbFlags);
  58.    return(mbResult);
  59. }
  60.  
  61.